package com.siki.controller;

import com.siki.config.filterConfig.jwtConfig.annotation.PassToken;
import com.siki.config.filterConfig.jwtConfig.annotation.UserLoginToken;
import com.siki.dto.position.GetPositionListDTO;
import com.siki.dto.position.ReportPositionDTO;
import com.siki.service.UserTalentPositionService;
import com.siki.utils.JsonInfoReturn;
import com.siki.vo.position.TalentPositionUserListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.core.Authentication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

@Api(tags = "用户 - 岗位相关操作接口")
@RestController
@RequestMapping("/api/vi/siki/user/talent_position")
@CrossOrigin
@UserLoginToken
public class UserTalentPositionController {
    private final UserTalentPositionService userTalentPositionService;

    public UserTalentPositionController(UserTalentPositionService userTalentPositionService) {
        this.userTalentPositionService = userTalentPositionService;
    }

    @ApiOperation(value = "[查询接口] - 普通用户查询岗位接口",response = TalentPositionUserListVO.class,httpMethod = "POST")
    @RequestMapping(value = "/get_position",method = RequestMethod.POST)
    @PassToken
    public JsonInfoReturn getPosition(@RequestBody @Validated GetPositionListDTO dto){
        userTalentPositionService.getPositionList(dto);
        return JsonInfoReturn.success();
    }

    @ApiOperation(value = "[提交接口] - 普通用户报名岗位接口",httpMethod = "POST",consumes = "application/json")
    @RequestMapping(value = "/save_apply_position/{id}",method = RequestMethod.POST)
    public JsonInfoReturn saveApplyPosition(@PathVariable("id") @NotNull Long id, Authentication authentication){
        userTalentPositionService.saveApplyPosition(id,authentication.getName());
        return JsonInfoReturn.success();
    }

    @ApiOperation(value = "[提交接口] - 用户举报虚假岗位",httpMethod = "POST",consumes = "application/json")
    @RequestMapping(value = "/report_position")
    public JsonInfoReturn reportPosition(@RequestBody ReportPositionDTO dto, Authentication authentication){
        userTalentPositionService.reportPosition(dto,authentication.getName());
        return JsonInfoReturn.success();
    }
}
